<%--
  Created by IntelliJ IDEA.
  User: zx
  Date: 2019/6/5
  Time: 下午 3:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>不在职记录</title>
    <script>
        function revers() {
            window.location.href = document.referrer;
        }
    </script>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/common/layui/css/layui.css"
          media="all">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/common/bootstrap/css/bootstrap.css"
          media="all">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/personal.css" media="all">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/kkpagerOrange.css">
    <script src="js/jquery2.js"></script>
    <script src="${pageContext.request.contextPath}/js/kkpager.min.js"></script>
</head>
<body>
<section class="layui-larry-box">
    <div class="layui-form news_list">
        <table class="layui-table">
            <thead>
            <tr>
                <th>日志主键</th>
                <th>访问时间</th>
                <th>操作者用户名</th>
                <th>访问ip</th>
                <th>访问资源url</th>
                <th>执行时长</th>
                <th>访问方法</th>
            </tr>
            </thead>
            <tbody id="tbody">

            </tbody>
            <script>
                $(function () {
                    $.ajax({
                        type: "get",
                        url: "${pageContext.request.contextPath}/sysLog/querySysLogAll",
                        dataType: "json",
                        data: $("#limitQuery").serialize(),
                        success: function (data) {
                            $.each(data, function (index, da) {
                                var time = new Date(da.visitTime);
                                var today = time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate();
                                var rows = "<tr>" +
                                    "<th>" + da.id + "</th>" +
                                    "<th>" + today + "</th>" +
                                    "<th>" + da.username + "</th>" +
                                    "<th>" + da.ip + "</th>" +
                                    "<th>" + da.url + "</th>" +
                                    "<th>" + da.executionTime + "</th>" +
                                    "<th>" + da.method + "</th>" +
                                    "</tr>"
                                $("#tbody").append(rows);
                            })
                        },
                        error: function () {
                            window.location.href = "404.jsp";
                        }
                    });
                });
            </script>
        </table>
        <form id="limitQuery">
            <%--分页用的用于传值--%>
            <input type="text" hidden name="i" value="1">
            <%--按钮值传入input--%>
            <input type="text" hidden name="state" value="">
            <%--跳转input框--%>
            <input type="text" hidden name="reverse" value="">
        </form>
        <%--分页--%>
        <div align="center">
            <div class="layui-btn-group">
                <button value="首页" class="layui-btn layui-btn-small layui-btn-primary"><i class="layui-icon">首页</i>
                </button>
                <button value="上一页" class="layui-btn layui-btn-small layui-btn-primary"><i
                        class="layui-icon">&#xe603;</i></button>
                <button value="下一页" class="layui-btn layui-btn-small layui-btn-primary"><i
                        class="layui-icon">&#xe602;</i></button>
                <button value="尾页" class="layui-btn layui-btn-small layui-btn-primary"><i class="layui-icon">尾页</i>
                </button>
                输入页数:<input type="text" name="reversex" style="width: 45px"/>
                <button value="跳转" class="layui-btn layui-btn-small layui-btn-primary"><i class="layui-icon">跳转</i>
                </button>
            </div>
        </div>
        <script>
            $(function () {
                //分页查询
                $(".layui-btn.layui-btn-small.layui-btn-primary").on({
                    "click": function () {
                        $("[name=state]").val($(this).val());
                        $("[name=reverse]").val($("[name=reversex]").val());
                        $.ajax({
                            type: "get",
                            url: "${pageContext.request.contextPath}/sysLog/querySysLogAll",
                            data: $("#limitQuery").serialize(),
                            dataType: "json",
                            success: function (data) {
                                $("tbody").empty();
                                $.each(data, function (index, da) {
                                    var time = new Date(da.visitTime);
                                    var today = time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate();
                                    var rows = "<tr>" +
                                        "<th>" + da.id + "</th>" +
                                        "<th>" + today + "</th>" +
                                        "<th>" + da.username + "</th>" +
                                        "<th>" + da.ip + "</th>" +
                                        "<th>" + da.url + "</th>" +
                                        "<th>" + da.executionTime + "</th>" +
                                        "<th>" + da.method + "</th>" +
                                        "</tr>"
                                    $("#tbody").append(rows);
                                })
                            },
                            error: function () {
                                window.location.href = "404.jsp";
                            }
                        });
                    }
                })

            })
        </script>
    </div>
</section>
</body>
</html>
